package com.sunny.ynhz.ui;

import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.sunny.ynhz.R;
import com.sunny.ynhz.ui.base.AppBaseTitleBarActivity;
import com.sunny.ynhz.ui.index.RankNaviFragment;
import com.sunny.ynhz.ui.lake.LakeNewsFragment;
import com.sunny.ynhz.ui.lake.PatrolRiverFragment;
import com.sunny.ynhz.utils.SwitchFragmentUtils;

import butterknife.BindView;

/**
 * Created by huhuan123 on 2018/5/21.
 */

public class LakeMsgActivity extends AppBaseTitleBarActivity implements RadioGroup.OnCheckedChangeListener {
    @BindView(R.id.rb_news)
    RadioButton rb_news;
    @BindView(R.id.rb_xunhe)
    RadioButton rb_xunhe;
    private SwitchFragmentUtils switchFragmentUtils;
    private RadioGroup rg_contain;
    private PatrolRiverFragment patrolRiverFragment;
    LakeNewsFragment lakeNewsFragment;
    private RankNaviFragment rankNaviFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lake_yi_long_activity);
        initView();
        setTitle("异龙湖");
        switchFragmentUtils = new SwitchFragmentUtils(this, getSupportFragmentManager());
        lakeNewsFragment = new LakeNewsFragment();
        Bundle lakeBundle = new Bundle();
        lakeBundle.putInt("id", 10);
        lakeBundle.putString("title", "异龙湖");
        rb_news.setChecked(true);
        switchFragmentUtils.swithFragment(lakeNewsFragment);
        patrolRiverFragment = new PatrolRiverFragment();
        lakeNewsFragment.setArguments(lakeBundle);
        rankNaviFragment = RankNaviFragment.getRankNaviFragment();
        rg_contain.setOnCheckedChangeListener(this);



    }

    public void initView() {
        rg_contain = findViewById(R.id.rg_contain);
    }

    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {
        if (i == R.id.rb_news)
            switchFragmentUtils.swithFragment(lakeNewsFragment);
        else if(i==R.id.rb_xunhe){
            switchFragmentUtils.swithFragment(patrolRiverFragment);
        }
        else if(i==R.id.rb_yzyx){
            switchFragmentUtils.swithFragment(rankNaviFragment);
        }

    }
}
